import * as types from '../mutation-types'

// initial state
const state = {
  isShowConfirmBtn: false,
  isSupportSelectMore: false,
  query: {},
  multiSelectedData: {},
  countClick: 0
}

// getters
const getters = {
  getShowConfirmBtn: state => state.isShowConfirmBtn,
  getSupportSelectMore: state => state.isSupportSelectMore,
  getQuery: state => state.query,
  getMultiSelectedData: state => state.multiSelectedData,
  getCountClick: state => state.countClick
}

// actions
const actions = {
  setQuery ({ commit }, query) {
    commit(types.SET_QUERY, query)
  },
  setShowConfirmBtn ({ commit }, isShow) {
    commit(types.SET_IS_SHOW_CONFIRM_BTN, isShow)
  },
  setSupportSelectMore ({ commit }, isSupport) {
    commit(types.SET_IS_SUPPORT_SELECT_MORE, isSupport)
  },
  setMultiSelectedData ({ commit }, multiSelected) {
    commit(types.SET_SELECTED_TIME, multiSelected)
  },
  setCountClick ({ commit }, countClick) {
    commit(types.SET_COUNT_CLICK, countClick)
  }
}

// mutations
const mutations = {
  [types.SET_QUERY] (state, query) {
    state.query = query
  },
  [types.SET_IS_SHOW_CONFIRM_BTN] (state, isShow) {
    state.isShowConfirmBtn = isShow
  },
  [types.SET_IS_SUPPORT_SELECT_MORE] (state, isSupport) {
    state.isSupportSelectMore = isSupport
  },
  [types.SET_SELECTED_TIME] (state, multiSelected) {
    state.multiSelectedData = multiSelected
  },
  [types.SET_COUNT_CLICK] (state, count) {
    state.countClick = count
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
